//状态对照表，前端与value对应：一般用汉字表示，后端与code对应：一般用10，20，30...表示
//前端需要的状态发生变化时，只需修改value
//后端需要的状态发生变化时，只需修改code
//读取code:this.appState.approvalState.all.code
//读取value:this.appState.approvalState.all.value
export const appState = {
	saleGoodsState: {
		all: { code: null, value: "全部", color: 'blue' },
		unConfirm: { code: '待确认', value: "待确认", color: 'blue' },
		unDelivery: { code: '待配送', value: "待配送", color: 'blue' },
		unReceive: { code: '待收货', value: "待收货", color: 'blue' },
		unSettle: { code: '待结算', value: "待结算", color: 'blue' },
		unInvoice: { code: '待开票', value: "待开票", color: 'blue' },
		settling: { code: '结算中', value: "结算中", color: 'blue' },
		completed: { code: '已完成', value: "已完成", color: 'green' },
		unPush: { code: '未推送', value: "未推送", color: 'purple' },//只有未推送时能推送
		pushed: { code: '已推送', value: "已推送", color: 'blue' },
		audit: { code: '待审核', value: "待审核", color: 'blue' },
		audited: { code: '已审核', value: "已审核", color: 'green' },
		reject: { code: '已驳回', value: "已驳回", color: 'red' },
		unComplete: { code: '待完善', value: "待完善", color: 'orange' },
	},
	purOrderState: {
		all: { code: null, value: "全部", color: 'blue' },
		unPush: { code: '未推送', value: "未推送", color: 'purple' },
		pushed: { code: "已推送", value: "已推送", color: 'blue' },
		unConfirm: { code: '待确认', value: "待确认", color: 'blue' },
		confirmed: { code: '已确认', value: "已确认", color: 'green' },
		refused: { code: '已拒绝', value: "已拒绝", color: 'red' },
		unDelivery: { code: '待配送', value: "待配送", color: 'blue' },
		partDelivery: { code: '部分配送', value: "部分配送", color: 'blue' },
		deliverying: { code: '配送中', value: "配送中", color: 'blue' },
		unReceive: { code: '待收货', value: "待收货", color: 'blue' },
		refusedGoods: { code: '已拒收', value: "已拒收", color: 'red' },
		received: { code: '已收货', value: "已收货", color: 'green' },
		partReceived: { code: '部分收货', value: "部分收货", color: 'pink' },
		received: { code: '部分收货', value: "部分收货", color: 'green' },
		unSettle: { code: '待结算', value: "待结算", color: 'blue' },
		settling: { code: '结算中', value: "结算中", color: 'blue' },
		settled: { code: '已结算', value: "已结算", color: 'blue' },
		unInvoice: { code: '待开票', value: "待开票", color: 'blue' },
		completed: { code: '已完成', value: "已完成" }
	},
	saleOrderState: {
		all: { code: null, value: "全部", color: 'blue' },
		unPush: { code: '未推送', value: "未推送", color: 'purple' },
		pushed: { code: "已推送", value: "已推送", color: 'blue' },
		unConfirm: { code: '待确认', value: "待确认", color: 'blue' },
		confirmed: { code: '已确认', value: "已确认", color: 'green' },
		refused: { code: '已拒绝', value: "已拒绝", color: 'red' },
		unDelivery: { code: '待配送', value: "待配送", color: 'blue' },
		partDelivery: { code: '部分配送', value: "部分配送", color: 'blue' },
		deliverying: { code: '配送中', value: "配送中", color: 'blue' },
		unReceive: { code: '待收货', value: "待收货", color: 'blue' },
		received: { code: '已收货', value: "已收货", color: 'green' },
		partingReceived: { code: '部分收货', value: "部分收货", color: 'pink' },
		refusedGoods: { code: '已拒收', value: "已拒收", color: 'red' },
		unSettle: { code: '待结算', value: "待结算", color: 'blue' },
		settling: { code: '结算中', value: "结算中", color: 'blue' },
		settled: { code: '已结算', value: "已结算", color: 'blue' },
		unInvoice: { code: '待开票', value: "待开票", color: 'blue' },
		completed: { code: '已完成', value: "已完成" }
	},
	deliveryState: {
		all: { code: null, value: "全部", color: 'blue' },
		unConfirm: { code: '待确认', value: "待确认", color: 'blue' },
		unDelivery: { code: '待配送', value: "待配送", color: 'blue' },
		unReceive: { code: '待收货', value: "待收货", color: 'blue' },
		revoked: { code: '已作废', value: "已作废", color: 'red' },
		received: { code: '已收货', value: "已收货", color: 'green' },
		partReceived: { code: '部分收货', value: "部分收货", color: 'green' },
		rejected: { code: '已拒收', value: "已拒收", color: 'orange' },
		unSettle: { code: '30', value: "待结算", color: 'blue' },
		unInvoice: { code: '40', value: "待开票", color: 'blue' },
		settling: { code: '60', value: "结算中", color: 'blue' },
		completed: { code: '70', value: "已完成", color: 'blue' }
	},
	settlementState: {
		all: { code: null, value: "全部", color: 'blue' },
		unSettle: { code: '30', value: "待结算", color: 'blue' },
		unInvoice: { code: '40', value: "待开票", color: 'blue' },
		completed: { code: '70', value: "已完成", color: 'blue' }
	},
	approvalState: {
		all: { code: null, value: "全部", color: 'blue' },
		normal: { code: '正常', value: "正常", color: 'blue' },
		overdue: { code: '已过期', value: "已过期", color: 'blue' },
		nearOverdue: { code: '即将过期', value: "即将过期", color: 'blue' }
	},
	invoiceState: {
		all: { code: null, value: "全部", color: 'blue' },
		unConfirm: { code: '已开具', value: "已开具", color: 'blue' },
		redFlush: { code: '红冲', value: "红冲", color: 'blue' },
		revoked: { code: '已作废', value: "已作废", color: 'red' },
		confirmed: { code: '已确认', value: "已确认", color: 'green' },
		rejected: { code: '已拒绝', value: "已拒绝", color: 'orange' },
	},
	zhuangTai: {
		all: { code: null, value: "全部", color: 'blue' },
		normal: { code: '正常', value: "正常", color: 'blue' },
		overdue: { code: '已过期', value: "已过期", color: 'blue' },
		nearOverdue: { code: '即将过期', value: "即将过期", color: 'blue' }
	}
}
//通过code和value查找状态，找到返回 "":{code:"",value:"",color:''},未找到返回-1
export function findState (code, value, statefield) {
	let stateObj = appState[statefield]
	for (const key in stateObj) {
		if (stateObj[key].code == code || stateObj[key].value == value) {
			return stateObj[key]
		}
	}
	return -1
}